home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 8.9 KB | 310 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWOvlShp.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWDFAULT_H
- #include "FWDfault.h"
- #endif
-
- #ifndef FWSHAPE_H
- #include "FWShape.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWARCSHP_H
- #include "FWArcShp.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWRGNSHP_H
- #include "FWRgnShp.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _TRNSFORM_
- #include <Trnsform.h>
- #endif
-
- //==============================================================================
- // •• RunTime Info
- //==============================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphx
- #endif
-
- //==============================================================================
- // •• class FW_COvalShape
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::FW_COvalShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::FW_COvalShape() :
- FW_CShape()
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::FW_COvalShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::FW_COvalShape(const FW_CRect& rect) :
- FW_CShape()
- {
- SetRep(new FW_COvalShapeRep(rect));
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::FW_COvalShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::FW_COvalShape(const FW_COvalShape& other) :
- FW_CShape(other)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::FW_COvalShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::FW_COvalShape(FW_COvalShapeRep* rep) :
- FW_CShape(rep)
- {
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::operator=
- //------------------------------------------------------------------------------
-
- FW_COvalShape& FW_COvalShape::operator=(const FW_COvalShape& other)
- {
- SetRep(other.GetRep());
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::operator=
- //------------------------------------------------------------------------------
-
- FW_COvalShape& FW_COvalShape::operator=(FW_COvalShapeRep* other)
- {
- SetRep(other);
- return *this;
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::operator FW_CRectShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::operator FW_CRectShape() const
- {
- FW_CRectShape rectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
- rectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return rectShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::operator FW_CRoundRectShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::operator FW_CRoundRectShape() const
- {
- FW_CRoundRectShape roundRectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), FW_kZeroPoint);
- roundRectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return roundRectShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::operator FW_CArcShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::operator FW_CArcShape() const
- {
- FW_CArcShape arcShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), 0, 0);
- arcShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return arcShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::operator FW_CLineShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::operator FW_CLineShape() const
- {
- FW_CRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
- FW_CLineShape lineShape(rect[FW_kTopLeft], rect[FW_kBotRight]);
- lineShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return lineShape;
- }
-
- //------------------------------------------------------------------------------
- // FW_COvalShape::operator FW_CRegionShape
- //------------------------------------------------------------------------------
-
- FW_COvalShape::operator FW_CRegionShape() const
- {
- XMPShape *xmpShape = NULL;
-
- #ifdef FW_BUILD_MAC
- GrafPtr svPort;
- ::GetPort(&svPort);
- ::SetPort(gGraphicGlobales.gScratchWindow);
- ::OpenRgn();
- FW_SPlatformRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
- ::FrameOval(&rect);
- FW_PlatformRegion rgn = ::NewRgn();
- ::CloseRgn(rgn);
- xmpShape = ::NewXMPShape(rgn);
- ::SetPort(svPort);
- #endif
-
- #ifdef FW_BUILD_WIN
- NotYetImplemented();
- #endif
-
- FW_CRegionShape regionShape(xmpShape);
- regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
- return regionShape;
- }
-
- //==============================================================================
- // •• class FW_COvalShapeRep
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • FW_COvalShapeRep::FW_COvalShapeRep
- //------------------------------------------------------------------------------
-
- FW_COvalShapeRep::FW_COvalShapeRep() :
- FW_CBoundedShapeRep(gGraphicGlobales.gOval, FW_CRect(0,0,0,0))
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_COvalShapeRep::FW_COvalShapeRep
- //------------------------------------------------------------------------------
-
- FW_COvalShapeRep::FW_COvalShapeRep(const FW_CRect& rect) :
- FW_CBoundedShapeRep(gGraphicGlobales.gOval, rect)
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_COvalShapeRep::~FW_COvalShapeRep
- //------------------------------------------------------------------------------
-
- FW_COvalShapeRep::~FW_COvalShapeRep()
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_COvalShapeRep::Draw
- //------------------------------------------------------------------------------
-
- void FW_COvalShapeRep::Draw(FW_CGraphicContext* graphicContext)
- {
- FW_ShapeFills shapeFill = GetShapeFill();
-
- if (shapeFill == FW_kNullShape)
- return;
-
- graphicContext->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kGeometricShape, shapeFill);
-
- FW_SPlatformRect rect = graphicContext->AsPlatformRect(fRect);
-
- #ifdef FW_BUILD_MAC
- if (shapeFill == FW_kFramed)
- ::FrameOval(&rect);
- else
- ::PaintOval(&rect);
- #endif
- #ifdef FW_BUILD_WIN
- ::Ellipse(graphicContext->GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_COvalShapeRep::DrawOval
- //------------------------------------------------------------------------------
-
- void FW_COvalShapeRep::DrawOval(FW_CGraphicContext* graphicContext, const FW_CRect& rect)
- {
- if (gGraphicGlobales.gOval.fFill == FW_kNullShape)
- return;
-
- graphicContext->SelectInkAndStyle(gGraphicGlobales.gOval.fInk, gGraphicGlobales.gOval.fStyle, FW_kGeometricShape, gGraphicGlobales.gOval.fFill);
-
- FW_SPlatformRect qdRect = graphicContext->AsPlatformRect(rect);
-
- #ifdef FW_BUILD_MAC
- if (gGraphicGlobales.gOval.fFill == FW_kFramed)
- ::FrameOval(&qdRect);
- else
- ::PaintOval(&qdRect);
- #endif
- #ifdef FW_BUILD_WIN
- ::Ellipse(graphicContext->GetHDC(), qdRect.left, qdRect.top, qdRect.right, qdRect.bottom);
- #endif
- }
-
- //------------------------------------------------------------------------------
- // • FW_COvalShapeRep::SetAsDefault
- //------------------------------------------------------------------------------
-
- void FW_COvalShapeRep::SetAsDefault() const
- {
- SetDefaultProperties(gGraphicGlobales.gOval);
- }
-
- //------------------------------------------------------------------------------
- // • FW_COvalShapeRep::HitTest
- //------------------------------------------------------------------------------
-
- FW_HitTestPart FW_COvalShapeRep::HitTest(const FW_CPoint& test) const
- {
- return FW_kOutside;
- }
-
- //----------------------------------------------------------------------------------------
- // • FW_COvalShapeRep::Copy
- //----------------------------------------------------------------------------------------
-
- FW_COvalShape FW_COvalShapeRep::Copy() const
- {
- FW_COvalShape oval(fRect);
- return oval;
- }
-
-